<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<head>
<title> 管理后台 -开心吧   版主</title>
<jsp:include page="/public/header-meta.jsp"></jsp:include>
<jsp:include page="/public/header.jsp"></jsp:include>
</head>
<body id="startbbs">
<div style="color:red">
    <s:fielderror />
</div>
<div id="wrap">
<div class="container" id="page-main" >
<div class="row">
<jsp:include page="leftbar.jsp"></jsp:include>
<div class='col-xs-12 col-sm-6 col-md-9' >

<div class='box'>
<div class='cell'>
<a href="welcome" class="startbbs1">开心吧</a> <span class="chevron">&nbsp;›&nbsp;
</span> <a href="admin!sectionList">管理后台</a> <span class="chevron">&nbsp;›&nbsp;
</span> ${sname}
</div>
<div class='cell'>
<table class='topics table' >
<thead>
<tr>
<td align='left' class='auto'><input id="checkall" type="checkbox" ></td>
<td  align="center" class='w50'>PID</td>
<td align='center' class='auto'>名称</td>
<td align='center' class='auto'>路径</td>
<td align="center" class='auto'>图标</td>
<td align="center" class='auto'>子菜单</td>
<td align='center'>操作</td>
</tr>
</thead>
<tbody>
<s:iterator value="list">
<tr class='center' >
	<td class='auto' align='left'>
		<input name="" value="${pid}" type="checkbox" id="check">
	</td>
	<td class='auto'>${pid }</td>
	</td>
	<td class='auto'>${name }</td>
	<td class='auto'>${url}</td>
	<td align='center' class='auto'>${icon }</td>
	<td align='center' class='auto'>
	<s:iterator value="children"> ${name},
	</s:iterator>
	</td>
<td class='w100'>
<a href="javascript:void(0)"  class="btn btn-primary btn-sm" 
onclick="doedit('${pid}','${name }','${url}','${icon}','${parentid.pid}')">编辑</a>
<a href="privi!deletePrivi?pid=${pid} " class="btn btn-sm btn-danger" onclick=" return confirm('确定删除？')" rel="nofollow">删除</a>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<div class='form-actions'>
<input class="btn btn-primary btn-danger" name="batch_del" type="submit" value="批量删除" />
<a class="btn btn-primary" data-toggle="modal" href="#modal-id">添加</a>
</div>
</div>
<div align='center' class='inner'>分页 未完成<div>
<ul class='pagination'></ul>
</div></div></div></div></div></div></div>



<jsp:include page="/public/footer.jsp"></jsp:include>
<div class="modal fade" id="modal-id">
		<div class="modal-dialog">
		<form accept-charset="UTF-8" action="privi!addPrivi" method="post" class="form-horizontal uc-form" id="add_group">
		<s:token/>
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h3 class="modal-title"> 添加权限</h3>
				</div>
				<div class="modal-body">
				<!-- form start -->
				<section class="box-input-txt">
				<ul>
				<li class="form-group">
					<input class="form-control" type="text" name="name" placeholder="请输入权限名称" required>
				</li>
				<li class="form-group">
					<input class="form-control" type="text" name="url" placeholder="请输入路径" required >
				</li>
				<li class="form-group">
					<input class="form-control" type="text" name="icon" placeholder="图标" required >
				</li>
				
				<li class="form-group">
					<select class="form-control"  name="parentId" id="t">
						<option value="0">请选择父菜单</option>
						<s:iterator var="privi" value="privi">
						<option value="${privi.pid }">${privi.name }</option >
						</s:iterator>
					</select>
				</li>
				</ul>
				<div>
				<button type="submit" class="btn btn-primary btn-block">保存</button>
				</div>
				<div class="tips-error bg-danger">错误提示</div>
				</section>
				
				<!-- form end -->
				</div>
			</div><!-- /.modal-content -->
			</form>
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	
	<div class="modal fade" id="edit_privi">
		<div class="modal-dialog modal-sm">
		<form accept-charset="UTF-8" action="privi!updatePrivi" method="post" class="form-horizontal uc-form">
		<s:token/>
		<input type="hidden" name="pid" id="pid">
		<input type="hidden" name="parentId" id="parentid" >
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h3 class="modal-title"> 编辑权限</h3>
				
				</div>
				<div class="modal-body">
				<!-- form start -->
				<section class="box-input-txt">
				<ul>
					
						<li class="form-group">
						<input class="form-control" type="text" name="name" id="name" placeholder="请输入权限名称" required>
						</li>
						<li class="form-group">
						<input class="form-control" type="text" name="url" id="url" placeholder="请输入路径" required >
						</li>
						<li class="form-group">
							<select class="form-control"  name="select" id="select"  onchange="parentid.value=this.options[this.selectedIndex].value">
							<option value="0">请选择权限</option >
							<s:iterator var="privi" value="list">
							<option value="${privi.pid }">${privi.name }</option >
							</s:iterator>
							</select>
						</li>
				</ul>
				<div>
				<button type="submit" class="btn btn-primary btn-block">保存</button>
				</div>
				<div class="tips-error bg-danger">错误提示</div>
				</section>
				
				<!-- form end -->
				</div>
			</div><!-- /.modal-content -->
			</form>
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
<script type="text/javascript">
	function doedit(pid,name,url,icon,parentid){
		$("#pid").attr("value",pid);
		$("#name").attr("value",name);
		$("#url").attr("value",url);
		$("#icon").attr("value",icon);
		//$("#parentid").attr("value",parentid);
		if(parentid!=0||parentid!=null){
			$("#select").find("option[value="+parentid+"]").attr("selected",true);	
			$("#parentid").attr("value",parentid);
		}else{
			$("#select").find("option[value=0]").attr("selected",true);
			
		}
		$('#edit_privi').modal('show').on('shown',function(){
		});
	}
</script>
<script type="text/javascript">
	$(document).ready(function(){
  		$("#checkall").bind('click',function(){
  		$("input:checkbox").prop("checked",$(this).prop("checked"));//全选
  	});
});
</script>
</body></html>

